﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using TestWif3.BingService;

namespace TestWif3
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SearchRequest request = new SearchRequest();
            request.Web = new TestWif3.BingService.WebRequest();
            request.Web.Count = 10;
            request.AppId = "E9B87CC640ECCFEDD5EFC730349D2AD80478762C";
            request.Query = query.Text;
            request.Market = "fr-FR";
            request.Sources = new SourceType[] { SourceType.Web, SourceType.Image, SourceType.Video, SourceType.News };

            BingPortTypeClient client = new BingPortTypeClient();
            client.SearchCompleted += new EventHandler<SearchCompletedEventArgs>(client_SearchCompleted);
            client.SearchAsync(request);
        }
        void client_SearchCompleted(object sender, SearchCompletedEventArgs e)
        {
            //MessageBox.Show(e.Result.Image.Results);
            resultStandard.ItemsSource = e.Result.Video.Results;
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {

            MessageBox.Show("test");
            var source = (e.OriginalSource as Button);
            var video = source.DataContext as VideoResult;
            MessageBox.Show(video.Title);
        }
    }
}
